package day3.demo8_方法锁;

public class Sell implements Runnable{

    static int sum=1000;
    @Override
    public void run() {
        while (sum>0){
              sell();
        }
    }

    static synchronized void sell(){
        if(sum<=0){
            return;
        }
        System.out.println(Thread.currentThread().getName() + "卖出第" + sum + "张票");
        try {
            Thread.sleep(1);
        } catch (InterruptedException e) {}
        sum--;
    }
}
